for(var i = 0; i < $("img").length; i++) {
	var id = $("img")[i].src;
	var id_data = id.substring("3");
	$.ajax({
		type: "get",
		url: "/Second_Project/orderid/" + id_data,
		async: false,
		success: function getimg(imgsrc) {
			$("img")[i].src = imgsrc;
		},
		error: function er() {

		}

	});
}

//注意：导航 依赖 element 模块，否则无法进行功能性操作
layui.use('element', function() {
	var element = layui.element;

	//…
});
layui.use('carousel', function() {
	var carousel = layui.carousel;
	//建造实例
	carousel.render({
		elem: '#test1',
		width: '100%',
		arrow: 'hover' //始终显示箭头
			//					,anim: 'updown' //切换动画方式
			,
		autoplay: false
	});
});
layui.use('carousel', function() {
	var carousel = layui.carousel;
	//建造实例
	carousel.render({
		elem: '#test3',
		width: '100%',
		arrow: 'hover' //始终显示箭头
			//					,anim: 'updown' //切换动画方式
			,
		autoplay: false
	});
});
$("#search").click(function() {
	var data = $(".title").serialize();
	console.log(data);
	search(data);
});

function search(data) {
	var order = ""; //定义用于拼接的字符串
	$.ajax({
		type: "get",
		url: "/Second_Project/dirtitlebook",
		dataType: 'json',
		data: data,
		async: false,
		success: function success(data) {
				$("section").html("");
			console.log(data.length);
			for(var i = 0; i < data.length; i++) {
				order = "<div class='order'><a href='*' class='a'><img class='orderimg' src='id: " +
					data[i].id + "'/><p>" +
					data[i].title + "</p><p>￥" +
					data[i].price + "</p></a></div>";
				$("section").append(order);
			}
		},
		error: function(msg) {
			console.log("error")
		}
	});

}
function searchcategory(data) {
	var order = ""; //定义用于拼接的字符串
	$.ajax({
		type: "get",
		url: "/Second_Project/dircategorybook",
		dataType: 'json',
		data: data,
		async: false,
		success: function success(data) {
				$("section").html("");
			console.log(data.length);
			for(var i = 0; i < data.length; i++) {
				order = "<div class='order'><a href='*' class='a'><img class='orderimg' src='id: " +
					data[i].id + "'/><p>" +
					data[i].title + "</p><p>￥" +
					data[i].price + "</p></a></div>";
				$("section").append(order);
			}
		},
		error: function(msg) {
			console.log("error")
		}
	});

}
function kj() {
	var data = "category=科技";
	searchcategory(data);
}

function xs() {
	var  data = "category=小说";
	searchcategory(data)
}

function jy() {
	var data = "category=教育";
	searchcategory(data)
}

function ls() {
	var data = "category=历史";
	searchcategory(data)
}

function wx() {
	var  data= "category=文学";
	searchcategory(data)
}

function zz() {
	var  data= "category=杂志";
	searchcategory(data)
}

